# -*- coding: UTF-8 -*-
"""
@author:zhangxing
@file:ip_proxy_utils.py
@time:2021/03/16
"""
import requests


def get_total_times():
    ip_count = requests.get("http://api.xkdaili.com/getUsedEachDay?key=1esxk4pm").text.strip()
    print(f"[info] 当前剩余总量: \033[32m【{10000-int(ip_count.split('：')[-1])}】\033[0m ; \033[32m【{ip_count}】\033[0m")
    return ip_count


def get_single_ip():
    ip_config = requests.get("http://api.xkdaili.com/ip?key=1esxk4pm&pattern=txt&count=1").text.strip()
    print(f"[info] 当前ip代理渠道: \033[32m【{ip_config}】\033[0m")
    get_total_times()
    return "http://" + ip_config


if __name__ == '__main__':
    print(get_single_ip())
